package com.example.springboot_c.Mapper;


import com.example.springboot_c.pojo.UserAccount;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserAccountMapper {
    @Select("SELECT * FROM user_account WHERE id = #{id}")
    UserAccount findById(Long id);

    @Select("SELECT * FROM user_account WHERE username = #{username} AND password = #{password}")
    UserAccount login(String username, String password);

    @Insert("INSERT INTO user_account(username, password, email, phone, points, created_at) " +
            "VALUES(#{username}, #{password}, #{email}, #{phone}, #{points}, NOW())")
    int register(UserAccount user);

    @Update("UPDATE user_account SET points = #{points} WHERE id = #{id}")
    int updatePoints(@Param("id") Long id, @Param("points") Integer points);

    @Select("SELECT * FROM user_account")
    List<UserAccount> findAll();
}